fix(gateway): ride out self-update port race + clearer update restart UX - #173
Merged
Conversation
After an in-place self-update relaunches the app, the freshly launched build raced the prior process's gateway-listener teardown. Auto-start did a single port probe, saw 45818 momentarily busy, and immediately deferred to the user with a "port not available" conflict prompt — even though the port frees within a second or two (the user could manually start on the same port right after). The abrupt close + spurious error made a normal update read as a crash. Backend: auto-start now waits up to ~6s (probing every 400ms) for the preferred port to free before treating it as a real conflict. The common case (port free) still returns on the first synchronous probe with no sleep. A genuine conflict (another app owning the port) stays busy the whole window and still surfaces the prompt. Added `wait_for_port_available` to the port service with unit tests for the free / held / freed-mid-wait cases. Frontend: extended AutoStartConflictResolver's poll schedule (~10s) so it is still polling when the backend resolves at the end of its wait window — otherwise a late conflict would never reach the prompt. UX: the manual "Download and Install" flow now flips to an explicit "Installing — McpMux will close and reopen automatically, this is expected" notice the moment the download finishes, so the window vanishing on Windows (passive NSIS installer kills the app) no longer looks like a crash. Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two issues reported around the in-place self-update / restart flow on Windows:
45818. Auto-start did a single port probe (lib.rs), saw the port momentarily busy, and immediately deferred to the user with a port-conflict prompt — even though, as the reporter observed, the port frees within a second or two (manually starting on the same port right after just works).Fix
Backend — ride out the restart race (
mcpmux-core,lib.rs)wait_for_port_available(port, timeout)ingateway_port_service: re-probes a busy port every 400ms for up toAUTOSTART_PORT_WAIT(~6s) before giving up. The common case (port already free) returns on the first synchronous probe with no sleep.is_port_available. A genuine conflict (another app permanently owning the port) stays busy the whole window and still surfaces the prompt — only the transient self-update race is absorbed.Frontend — keep the resolver polling long enough (
AutoStartConflictResolver)UX — make the restart expected (
UpdateChecker)Tests
wait_for_port_available: free (immediate), held (gives up), and freed-mid-wait (succeeds).cargo nextest -p mcpmux-core(139 passed),cargo clippy --workspace -D warnings,cargo fmt --check,pnpm typecheck,App.test.tsx(12 passed), ESLint — all green.Notes